<template>
    <el-form :inline="true" :model="firmFrom" class="demo-form-inline" ref="formRef">
        <el-form-item label="公司名称" prop="firmName">
            <el-input v-model="firmFrom.firmName" clearable />
        </el-form-item>
        <el-form-item label="项目名称" prop="projectName">
            <el-input v-model="firmFrom.projectName" clearable />
        </el-form-item>
        <el-form-item label="客户名称" prop="customerId">
            <el-select v-model="firmFrom.customerId" placeholder="请输入客户名称" :disabled="true" >
                <el-option v-for="item in customerList" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
        </el-form-item>
        <el-form-item label="负责人" prop="leader">
            <el-input v-model="firmFrom.leader" clearable />
        </el-form-item>
        <el-form-item class="btn">
            <el-button type="primary" @click="onSubmit(firmFrom)" class="submit" icon="Search">查找</el-button>
            <el-button type="primary" @click="onReset(formRef)" class="reset" icon="Refresh">重置</el-button>
        </el-form-item>
    </el-form>
</template>
<script setup>
import { ref, defineEmits, defineProps } from 'vue'
import {  getWorkApi } from '@/api/tickets'
let emit = defineEmits(['onSearch'])
let props = defineProps(['firmFrom'])
let formRef = ref(null)
// 查找
const onSubmit = (v) => {
    emit('onSearch', v)
}

// 重置
const onReset = (v) => {
    if (!v) return
    v.resetFields()
}
let customerList = reactive([

])

// 获取客户下拉菜单数据
const getWorkApiData = async (v = '') => {
    let params = { customerName: v }
    let { code, data } = await getWorkApi(params)
    if (code == 200) {
        data.forEach(v => {
            customerList.push({
                label: v.primaryClassification + '/' + v.customerName,
                value: v.customerId
            })
        });
    }
}



onMounted(() => {
    getWorkApiData()
})
</script>
<style scoped lang='scss'>
.demo-form-inline {


    .reset {
        background-color: #fff;
        color: #333;
    }

    .btn {
        margin-left: 32px;
    }
}
</style>
